package com.za.wbw.service.wap.impl;

import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import javax.management.Query;

import com.za.wbw.dao.wap.CommentDao;
import com.za.wbw.dao.wap.impl.CommentDaoImpl;
import com.za.wbw.model.wap.CommentInfo;
import com.za.wbw.model.wap.vo.CommentListVo;
import com.za.wbw.service.wap.CommentService;

public class CommentServiceImpl implements CommentService {
	private CommentDao commentDao;

	public int queryCommentCount() throws Exception{
		return this.getCommentDao().queryCommentCount();
	}
	public List<CommentListVo> queryCommentList(int shopId) throws Exception{
		List<CommentInfo> list = this.getCommentDao().queryCommentList(shopId);
		List<CommentListVo> vos= new ArrayList<CommentListVo>();
		for (CommentInfo info : list) {
			CommentListVo vo = new CommentListVo();
		    vo.setCommentId(info.getCommentId());
		    vo.setContent(info.getContent());
		    vo.setUserAlias(info.getUserAlias());
		    vo.setZoomOut(info.getZoomOut());
		    vo.setTasteName(info.getTasteName());
		    vo.setAttitudeName(info.getAttitudeName());
		    vo.setEnvironmentName(info.getEnvironmentName());
		    vo.setCreateTime(info.getCreateTime());
			vos.add(vo);
		}
		return vos;
	}
	
	public List<CommentListVo> queryCommentPage(Map<String, Object> pars) throws Exception{
		List<CommentInfo> list = this.getCommentDao().queryCommentPage(pars);
		List<CommentListVo> vos= new ArrayList<CommentListVo>();
		for (CommentInfo info : list) {
			CommentListVo vo = new CommentListVo();
		    vo.setCommentId(info.getCommentId());
		    vo.setContent(info.getContent());
		    vo.setUserAlias(info.getUserAlias());
		    vo.setZoomOut(info.getZoomOut());
		    vo.setTasteName(info.getTasteName());
		    vo.setAttitudeName(info.getAttitudeName());
		    vo.setEnvironmentName(info.getEnvironmentName());
		    vo.setCreateTime(info.getCreateTime());
			vos.add(vo);
		}
		return vos;
	}
	
	public CommentDao getCommentDao() {
		return commentDao;
	}

	public void setCommentDao(CommentDao commentDao) {
		this.commentDao = commentDao;
	}
}
